/*
 * @Author: your name
 * @Date: 2024-05-20 11:37:56
 * @LastEditTime: 2024-05-20 11:48:44
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\455.分发饼干.cpp
 */
/*
 * @lc app=leetcode.cn id=455 lang=cpp
 *
 * [455] 分发饼干
 */

// @lc code=start
class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        sort(g.begin(), g.end());
        sort(s.begin(), s.end());
        int cur = s.size()-1;
        int sum = 0;
        for(int i = g.size()-1; i >= 0; i--){
            if(cur >= 0 && s[cur] >= g[i]){
                // 这个饼干可以满足这个小孩
                cur--;
                sum++;
            }
        }
        return sum;

    }
};
// @lc code=end
// 对饼干和小孩胃口进行排序，然后按照 大饼干喂大胃口的原则分发
